function getHeader(){
    let time = Date.parse(new Date()) + "";
    return window.btoa(generateMixed(5) + reverse(time.substring(0,6)) + reverse(time.substring(6)) + generateMixed(5));
}
const _charStr = 'bacdefghjklmnopqrstuvwxyzBCDEFGHJKLMNOPQRSTUVWXYZ0123456789';

function generateMixed(len){
    let min = 0,max = _charStr.length-1, _str = '';
    len = len || 15;
    for(var i = 0, index; i < len; i++){
        index = (function(randomIndexFunc, i){
            return randomIndexFunc(min, max, i, randomIndexFunc);
        })(function(min, max, i, _self){
            let indexTemp = Math.floor(Math.random()*(max-min+1)+min),
                numStart = _charStr.length - 10;
            if(i===0&&indexTemp >=numStart){
                indexTemp = _self(min, max, i, _self);
            }
            return indexTemp ;
        }, i);
        _str += _charStr[index];
    }
    return _str;
}

function reverse(fist){
    let split = fist.split("");
    let result = "";
    for(var i = 0; i<split.length;i++){
        result += split[i]+generateMixed(1);
    }
    return result.replaceAll("6","A");
}

function randomNumber(maxNumber){
    let number = Math.round( Math.random()*1000);
    while (number < maxNumber){
        randomNumber(maxNumber);
    }
    return number;
}

function getHeader2(){
    let date = new Date();
    let month = date.getMonth() + 1
    let day = date.getDate()
    let dayValue = day * 9867
    return window.btoa(
        month +
        generateMixed(3) +
        month +
        generateMixed(3) +
        reverse(Date.parse(new Date())+"").replaceAll("1","f") +
        day +
        generateMixed(3) +
        dayValue
    )
}


export default {
    getHeader,
    getHeader2,
    generateMixed,
    reverse
}
